package com.sh1604.duitang.activity;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;

import com.google.gson.Gson;
import com.sh1604.duitang.R;
import com.sh1604.duitang.constant.UrlString;
import com.sh1604.duitang.mybean.FindImageBean;
import com.sh1604.duitang.utils.OKHttpUtils;

import java.io.IOException;

public class ImagedetailsActivity extends AppCompatActivity {

    private Context mContext;
    private WebView webView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_imagedetails);
        webView = (WebView) findViewById(R.id.webview1);
        OKHttpUtils.newInstance(mContext).getAsyncMainData(UrlString.URL_Image, new OKHttpUtils.MyCallBack() {
            @Override
            public void onFailure(IOException e) {
            }
            @Override
            public void onResponse(String result) {
                final FindImageBean bean = new Gson().fromJson(result,FindImageBean.class);
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        webView.loadUrl(bean.getData().getObject_list().get(0).getTarget());
                    }
                });
            }
        });

    }
}
